package org.exteen.exec;

import org.exteen.output.ExteenStream;
import org.exteen.parser.Attr;
import org.exteen.parser.Node;

public class XmlTag extends Tag {

     public static XmlTag INSTANCE = new XmlTag();

     public void doTag(ExteenContext ctx, ExteenStream stream) {

          Node node = ctx.getNode();
          stream.printTagOpen(node.getFullTag()); // <tag

          if (node.getAttributes() != null) {
               for (Attr a : node.getAttributes()) {
                    String ns = a.getNamespace();
                    if (ns == null) {
                         Object value = a.getValueObject(ctx);
                         if (value != null) {
                              stream.printAttribute(a.getKey(), escape(value));
                         }
                    }
               }
          }
          stream.printTagOpenEnd();
          // body
          super.doBody(ctx, stream);
          // end
          stream.printTagClose(node.getFullTag());
     }
}
